package com.bwie.controller;

import com.bwie.service.TOrderService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import com.bwie.vo.TbProdVo;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author:杨珂
 * @CreateTime: 2025-03-21
 */
@RestController
@RequestMapping("/order/index")
public class IndexController {

    @Autowired
    private TOrderService tOrderService;

    @PostMapping("/getOrderById/{id}")
    public R getOrderById(@PathVariable("id") Integer id) {
        return tOrderService.getOrderById(id);
    }

    /**
     * 分页获取订单
     *
     * @param pageInfoVo
     * @return
     */
    @ApiOperation("订单分页查询")
    @PostMapping("/getOrderList")
    public R getOrderList(@RequestBody PageInfoVo pageInfoVo) {
        return tOrderService.getOrderList(pageInfoVo);
    }

    /**
     * 购买商品接口
     *
     * @param prodVoList
     * @return
     */
    @PostMapping("/addOrder")
    public R addOrder(@RequestBody List<TbProdVo> prodVoList) {
        return tOrderService.addOrder(prodVoList);
    }

}
